home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / vedt.zip / WILDFILE.VDM < prev    next >
Text File  |  1990-08-15  |  5KB  |  182 lines

  1. !        Macro WILDFILE.VDM
  2. !
  3. !        Updated March 6, 1990
  4. !
  5. ! This macro runs any VEDIT command or another macro on an entire group of
  6. ! files.  The files may either be specified individually or with wildcards.
  7. !
  8. ! INTERNALLY:
  9. ! This macro generates in register 2 a sequence of open file, display
  10. ! filename, execute macro M(3), and close file instructions.
  11. !
  12. ! Register Usage:
  13. !
  14. !    2        Contains sequence of "EB","M(3)","EY" instructions
  15. !    3        Hold command or macro executed for each file
  16. !    8        Hold search string
  17. !    9        Hold filenames entered by user; replace string
  18. !
  19. !    Q80        User keyboard response to questions (temp)
  20. !    Q81        Flag whether macro stops after each filename
  21. !    Q84        Hold original ES 4 value
  22. !    Q86        ES 6 value
  23. !    Q88        ES 8 value
  24. !    Q89        ES 8 value
  25. !
  26. !****************************************************************************
  27. !
  28. !
  29. EE(@)                R* Check main buffer
  30. (.oa==0 | .of==0)[ EZY ][    R* If unaltered or no file open clear it
  31.     YA YEN            R* Else confirm saving it...
  32.     @YT"Do you want to save the file in the main edit buffer?" YEN
  33.     @YT"[S]ave file; [A]bandon file; [C]ancel macro : "
  34.     [ @XK(100)"" Q100&95XS(100) (Q100=="S | Q100=="A | Q100=="C)JL YA ] Q100:YD
  35.  
  36.     YEN
  37.     (Q100=="C)[ JO ]
  38.     (Q100=="S)[ EY ][ EZY ]    R* Save or abandon the file
  39.     ]
  40.  
  41. ES 4 1 .rvXS(84)    !Save original ES values; set new ones
  42. ES 6 0 .rvXS(86)
  43. ES 8 1 .rvXS(88)
  44. ES 9 1 .rvXS(89)
  45.  
  46. EE(2) EZY        !Switch to and empty edit buffer 2
  47.  
  48. YEC
  49. YT/
  50.         *****************************************
  51.         *                    *
  52.         *        VEDIT            *
  53.         *    Multi-file Macro Driver        *
  54.         *                    *
  55.         *****************************************
  56.  
  57. Enter the names of the files you want to operate on and <Enter>.
  58. (The wildcards '?' and '*' may be used).
  59.  
  60. Press <Enter> twice when done.
  61.  
  62. /
  63. !
  64. !    Query and get user response in Register #9.
  65. !    Expand wildcards into filenames.  Place filenames with complete
  66. !    pathname in edit buffer 2.
  67. !
  68. #[
  69. !FLOOP!
  70. :RQ(9)"Enter Filename: " (.u9=0)_JL
  71. :ED|R9                !Test if file(s) exist (.rv==0 if not)
  72. (.rv=0) [YT"File(s) not found.  Try again." YEN JP"FLOOP" ]
  73. Z .pXS(0)            !Goto end of buffer and save position
  74. YI 1ED|R9 -YI            !Insert directory into edit buffer 2
  75. Q0EJ                !Restore position
  76. F"Directory "            !Search for "Directory" header
  77. -K                !Delete partial header and previous blank line
  78. .pXS(0)                !Save current position
  79. $F"|>"                !Advance to end of line
  80. Q0,.pRC(3)            !Copy drive:pathname to register 3
  81. 0KK                !Delete rest of header
  82. !
  83. !    Cleanup filenames.
  84. !
  85. B #[$F"|<|>" ; 0KK ]        !Remove blank lines
  86. B #[F"*" ; 0KK ]        !Remove sub-directory entries containing "*"
  87. B #[F".EXE" ; 0KK ]        !Don't attempt to edit ".COM" or ".EXE" files
  88. B #[F".COM" ; 0KK ]
  89. B #$S"|W""            !Eliminate excess white space (in filenames)
  90. Q0EJ                !Restore position
  91. #[
  92.     $F"|<|X" ; -C RG(3)     !Precede each filename with full drive:pathname
  93.     (.os=4)[I"/"][I"\" ]    !Unix needs "/"; DOS needs "\"
  94. ]
  95. ]
  96. !
  97. ! Prompt for "C", "M" or "S"; convert to upper case; check for valid reply
  98. !
  99. #[ YEN XK(80)\Execute a [C]ommand, [M]acro, [S]earch or [R]eplace? (C/M/S/R): \
  100.   Q80&223 XS(80) ((Q80="C) ^ (Q80="M) ^ (Q80="S) ^ (Q80="R))_JL YA
  101. ]
  102.  
  103. (Q80="C)[ 2YEN :RQ(3)"Enter Command: "
  104.     ][
  105. (Q80="M)[
  106.     2YEN :RQ(9)"Enter filename of macro: "
  107.     +RL(3) |R9
  108.     ][
  109.     2YEN :RQ(8)"Enter search string (and Enter): "
  110.     !
  111.     ! Build macro in current edit buffer, 91EI and 93EI create brackets
  112.     ! Use 255(decimal) as explicit delimiters
  113.     !
  114.     (Q80="S)[
  115.         EE(@) EZY 91EI I"@_F" 255EI RG(8) 255EI
  116.         ][
  117.         YEN :RQ(9)"Enter replace string (and Enter): "
  118.         EE(@) EZY 91EI I"@_S" 255EI RG(8) 255EI RG(9) 255EI
  119.         ]
  120.     #[ YEN XK(80)\[D]isplay line or enter [V]isual Mode? (D/V): \
  121.        Q80&223 XS(80) ((Q80="D) ^ (Q80="V))_JL YA
  122.     ]
  123.  
  124.     (Q80="D)[
  125.         I" @YT\LINE:\ .lnXS(80) :XT(80) @YT\  \ 0TT" 93EI
  126.             ][
  127.             I"V" 93EI
  128.         ]
  129.     -#RC(3) EZY EE(2)        !Copy to register #3 and clear edit buffer
  130.     ]
  131.     ]
  132. !
  133. ! Does user want macro to pause after each filename?
  134. ! If Visual mode above, no need to pause
  135. !
  136. (Q80="V)[ "NXS(81)
  137.     ][
  138.     #[ YEN XK(81)\Should macro pause after each file is processed? (Y/N): \
  139.        Q81&223 XS(81) ((Q81="Y) ^ (Q81="N))_JL YA
  140.     ]
  141.     ]
  142. !
  143. !    Insert EB ...$ EW$ M(3) EY
  144. !
  145. B
  146. #[
  147.     .eof_JL
  148.     I"EB "
  149.     $F"|>"
  150.     (Q81="Y)[ I" YEN @YT\...Processing \ :EW 2YEN M(3) +@XK(80)\Press any key to continue...\ :EY"
  151.         ][
  152.           I" YEN @YT\...Processing \ :EW 2YEN M(3) :EY"
  153.         ]
  154.     :L
  155. ]
  156. !
  157. !    Make main buffer active and pre-clear it
  158. !
  159. EE(@)
  160. EZY
  161.  
  162. XK(81)"
  163. Press any key to begin operation..."
  164.  
  165. .wt>1[YWI]        !Delete any windows
  166. ES 4 Q84        !Restore most original ES values
  167. ES 6 Q86
  168. ES 9 Q89
  169.  
  170. (Q80="V)[
  171.     YWB(H) 1 YWS(H)
  172.     @YT"    Press [VISUAL EXIT] (<CTRL-E>) to search for next occurrence."
  173.     YWS(@)
  174.     ]
  175.  
  176. M(2)
  177.  
  178. ES 8 Q88        !Restore original ES value
  179.  
  180. (.mn<>"Z)[JM        !If macro not in register "Z", it is now done
  181.          ][ EXA ]    !Else we exit VEDIT
  182.